package job.relevance.anchor_weight;

import java.io.IOException;
import java.util.Iterator;

import mapred.base.TextReducer;

import org.apache.hadoop.io.Text;

public class RLV_AW_AnchorWeightSum_Reducer extends TextReducer {

    @Override
    public void reduce(Text key, Iterator<Text> values) throws IOException {
        double rank = 0;
        long count = 0;
        while (values.hasNext()) {
            String[] t = values.next().toString().split("\t");
            rank += Double.parseDouble(t[0]);
            count += Long.parseLong(t[1]);
        }
        this.output(key, new Text(String.valueOf(rank + "\t" + count)));
    }

    @Override
    public void setUp() {
    }

    @Override
    public void tearDown() throws IOException {
    }

}
